package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     * 根据菜品id查看套餐id
     * @param dishIds
     * @return
     */
    List<Long> getSetmealIdsByDishIds(List<Long> dishIds);

    /**
     * 根据套餐id查看包含数据
     * @param setmeal
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> selectBySetmealId(Setmeal setmeal);

    /**
     * 新增套餐菜品表数据
     * @param setmealDish
     */
    @Insert("insert into setmeal_dish (setmeal_id, dish_id, name, price, copies) values (#{setmealId}, #{dishId}, #{name}, #{price}, #{copies});")
    void insert(SetmealDish setmealDish);

    /**
     * 更新套餐菜品表数据
     * @param setmealDish1
     */
    @Update("update setmeal_dish set setmeal_id= #{setmealId}, dish_id = #{dishId}, name = #{name}, price = #{price}, copies = #{copies} where id = #{id}")
    void update(SetmealDish setmealDish1);

    /**
     * 删除套餐菜品表中套餐的数据
     * @param ids
     */
    void deleteSet(List<Long> ids);
}
